/**
 * 
 */
package com.wm.service.imp;

import java.util.List;

import com.wm.bean.Area;
import com.wm.bean.City;
import com.wm.bean.Scriptorium;
import com.wm.dao.AreaDAO;
import com.wm.dao.CityDAO;
import com.wm.dao.ScriptoriumDAO;
import com.wm.service.AreaService;
import com.wm.service.CityService;
import com.wm.service.ScriptoriumService;
import com.wm.service.web.PageList;
import com.wm.service.web.Pages;

/**
 * @author zhangbaochao
 *
 */
public class ScriptoriumServiceImp implements ScriptoriumService {
	
	private ScriptoriumDAO scriptoriumDAO;

	public ScriptoriumDAO getScriptoriumDAO() {
		return scriptoriumDAO;
	}

	public void setScriptoriumDAO(ScriptoriumDAO scriptoriumDAO) {
		this.scriptoriumDAO = scriptoriumDAO;
	}
	/**
	 * 保存Scriptorium对象
	 * 
	 * @param scriptorium
	 * 			Scriptorium
	 * @return Scriptorium
	 * 			Scriptorium
	 */
	public Scriptorium saveScriptorium(Scriptorium scriptorium){
		return this.getScriptoriumDAO().saveScriptorium(scriptorium);
	}
	
	/**
	 * 更新Scriptorium对象
	 * 
	 * @param scriptorium
	 * 			Scriptorium
	 * @return Scriptorium
	 * 			Scriptorium
	 */
	public Scriptorium updateScriptorium(Scriptorium scriptorium){
		return this.getScriptoriumDAO().updateScriptorium(scriptorium);
	}
	
	/**
	 * 根据ID删除Scriptorium对象
	 * 
	 * @param id
	 * 			long
	 */
	public void removeScriptoriumById(long id){
		this.getScriptoriumDAO().removeScriptoriumById(id);
	}
	
	/**
	 * 根据ID获取Scriptorium对象
	 * 
	 * @param id
	 * 			long
	 * @return Scriptorium
	 * 			Scriptorium
	 */
	public Scriptorium findScriptoriumById(long id){
		return this.getScriptoriumDAO().findScriptoriumById(id);
	}

	/**
	 * 根据参数获取Scriptorium对象列表
	 * 
	 * @param cityId
	 * 			long
	 * @param areaId
	 * 			long
	 * @param isShow
	 * 			int
	 * @param orderby
	 * @param ascOrDesc
	 * @return PageList
	 * 			PageList
	 */
	public PageList findScriptoriumsByScrNameCityIdAreaIdIsShow(String scrName,long cityId,long areaId,int isShow,String orderby,int ascOrDesc,Pages pages){
		PageList pl = new PageList();
        if (pages.getTotalNum() == -1) {
            pages.setTotalNum(this.getScriptoriumDAO().getScriptoriumNumByScrNameCityIdAreaIdIsShow(scrName,cityId, areaId, isShow));
        }
        pages.executeCount();
        if(pages.getTotalNum() == 0){
        	pl.setObjectList(null);
        	pl.setPages(pages);
        	return pl;
        }
        List l = this.getScriptoriumDAO().findScriptoriumsByScrNameCityIdAreaIdIsShow(scrName,cityId, areaId, isShow,orderby, ascOrDesc, pages.getSpage(), pages.getPerPageNum());
        if(l == null || l.isEmpty()){
	   		 pl.setObjectList(null);
	   	     pl.setPages(pages);
	   		 return pl;
		}else{
			pl.setObjectList(l);
	        pl.setPages(pages);
	        return pl;
		} 
	}
	/**
	 * 根据参数获取Scriptorium对象列表
	 */
	public List findScriptoriumsByScrInitialsScrAnglicScrPhoneticScrTypeAreaIdIsShow(String scrInitials,String scrAnglic,String scrPhonetic,int scrType,long areaId,int isShow,String orderby,int ascOrDesc){
        return this.getScriptoriumDAO().findScriptoriumsByScrInitialsScrAnglicScrPhoneticScrTypeAreaIdIsShow(scrInitials, scrAnglic, scrPhonetic, scrType, areaId, isShow, orderby, ascOrDesc);
	}
	
	/**
	 * 根据参数获取Scriptorium对象列表
	 * @param scrName
	 * @return
	 */
	public List findScriptoriumByScrName(String scrName){
		return this.getScriptoriumDAO().findScriptoriumByScrName(scrName);
	}
}
